package com.md.application.service;

import com.md.api.GlobalConfigApi;
import com.md.domain.service.ConfigDomainServices;
import com.md.model.system.CommonResult;
import com.md.request.GlobalConfigRequest;
import com.md.response.GlobalConfigResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 刘骄阳
 * 2024-12-15 1:46
 */
@Service
@RequiredArgsConstructor
public class GlobalConfigApplication implements GlobalConfigApi {
  private final ConfigDomainServices configDomainServices;

  @Override
  public CommonResult<List<GlobalConfigResponse>> list() {
    return CommonResult.success(configDomainServices.list());
  }

  @Override
  public CommonResult<GlobalConfigResponse> update(final GlobalConfigRequest request) {
    configDomainServices.updateConfig(request.getId(), request.getValue());
    return CommonResult.success();
  }
}
